package com.it.controller;

import com.it.pojo.Classes;
import com.it.service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ClassesController {

    @Autowired
    private ClassesService classesService;

    @RequestMapping("/classes")
    public List<Classes> selectByClasses(){
        return classesService.getAll();
    }

    @RequestMapping("/addClass")
    public void addClass(@RequestBody Classes cls) {
        classesService.add(cls);
    }

    @RequestMapping("/editClass")
    public void editClass(@RequestBody Classes cls) {
        classesService.update(cls);
    }

    @RequestMapping("/delClass/{id}")
    public void delClass(@PathVariable Integer id) {
        classesService.delete(id);
    }

}
